﻿using System;
using MosCraft.Materials;

namespace MosCraft
{
    //Used to group various blocks, was ENUM
    //But due to different logic states has been
    //chnaged to a Static class
    public class Material
    {
        public static readonly Material Air;
        public static readonly Material Grass;
        public static readonly Material Ground;
        public static readonly Material Wood;
        public static readonly Material Rock;
        public static readonly Material Water;
        public static readonly Material Leaves;
        public static readonly Material Plants;
        public static readonly Material Sand;

        private bool canBurn;
        private bool groundCover;
        private bool isTranslucent;
        private bool canHarvest;

        /// <summary>
        /// Static constructor called when program is ran
        /// used to define each of the material types
        /// </summary>
        static Material()
        {
            Air = new MaterialTransparent();
            Grass = new Material();
            Ground = new Material();
            Wood = (new Material()).setBurning();
            Rock = (new Material()).setNoHarvest();
            Water = new MaterialLiquid();
            Leaves = (new Material()).setBurning().setIsTranslucent();
            Plants = new MaterialLogic();
            Sand = new Material();
        }

        public Material()
        {
            canHarvest = true;
        }

        virtual public bool getIsLiquid()
        {
            return false;
        }

        virtual public bool isSolid()
        {
            return true;
        }

        virtual public bool getCanBlockGrass()
        {
            return true;
        }

        virtual public bool getIsSolid()
        {
            return true;
        }

        private Material setIsTranslucent()
        {
            isTranslucent = true;
            return this;
        }

        private Material setNoHarvest()
        {
            canHarvest = false;
            return this;
        }

        private Material setBurning()
        {
            canBurn = true;
            return this;
        }

        public bool getBurning()
        {
            return canBurn;
        }

        public Material setIsGroundCover()
        {
            groundCover = true;
            return this;
        }

        public bool getIsGroundCover()
        {
            return groundCover;
        }

        public bool getIsOpaque()
        {
            if (isTranslucent)
            {
                return false;
            }
            else
            {
                return getIsSolid();
            }
        }

        public bool getIsHarvestable()
        {
            return canHarvest;
        }

    }
}
